package com.ssms.service;

import com.ssms.commons.Result;
import com.ssms.dao.SysUserMapper;
import com.ssms.model.SysUser;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Service
public class SystemService {

    @Resource
    private SysUserMapper sysUserMapper;

    public Result login(SysUser sysUser, HttpSession session) {
        SysUser user = sysUserMapper.selectByPhone(sysUser);
        // 通过用户名查询出来后，对比传入的用户名数据
        if (user != null && sysUser.getPassword().equals(user.getPassword())) {
            session.setAttribute("sysUser", user); // 将用户对象存入session
            return Result.success();
        }
        return Result.failed("手机号或密码错误",500);
    }

}
